<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        年羹尧：<input type="text" v-model="title">
        <div v-text="msg"></div>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        // 创建 Vue 实例，得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {
                title: '江西总兵',
                msg: ''
            },
            methods: {},
            watch: {
                // 第一个参数是新数据，第二个参数是旧数据
                'title': function (newVal, oldVal) {
                    this.msg = '年羹尧从' + oldVal + '变成了' + newVal;
                },
            }
        });
    </script>
</body>

</html>